package com.spring.cloud.alibabaconsumer.configuration;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

@Configuration
public class TaskPoolConfig {

    /**
     * 自定义线程池
     * @return ThreadPoolExecutor
     */
    @Bean(name = "customTaskWorkPoolExecutor")
    public ThreadPoolExecutor customTaskWorkPoolExecutor() {
        ArrayBlockingQueue<Runnable> taskQueue = new ArrayBlockingQueue(25);
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(5, 50, 30000, TimeUnit.MILLISECONDS, taskQueue);
        return threadPoolExecutor;
    }

}
